<style>
	.fui-goods-list{width:100%;border-bottom: 1px dashed #e1ecee;padding-top:5px;padding-bottom:5px;}
	.fui-goods-list span{display: block;padding:0;}
</style>
<form class="form-horizontal form-validate" action="{if $edit_flag==1}{php echo webUrl('order/op/changeExpress')}{else}{php echo webUrl('order/op/send')}{/if}" method="post" enctype="multipart/form-data">
	<input type='hidden' name='id' value='{$id}' />

	<div class="modal-dialog">
           <div class="modal-content">
            <div class="modal-header">
                <button data-dismiss="modal" class="close" type="button">×</button>
                <h4 class="modal-title">{if $edit_flag==1}修改物流信息{else}订单发货{/if}</h4>
            </div>
            <div class="modal-body">
                   	<div class="form-group">
						<label class="col-sm-2 control-label">收 货 人</label>
						<div class="col-sm-9 col-xs-12">
							<div class="form-control-static">
								联系人: {$address['realname']} / {$address['mobile']} <br/>
								地    址: {$address['province']}{$address['city']}{$address['area']} {$address['address']}
							</div>
						</div>
					</div>
                                
					<div class="form-group">
						<label class="col-sm-2 control-label">快递公司</label>
						<div class="col-sm-9 col-xs-12">
							<select class="form-control" name="express" id="express">
                                <option value="" data-name="">其他快递</option>
                                {loop $express_list $value}
                                <option value="{$value['express']}" data-name="{$value['name']}">{$value['name']}</option>
                                {/loop}

							</select>
							<input type='hidden' name='expresscom' id='expresscom' value="{$item['expresscom']}"/>
						</div>
					</div>
					<div class="form-group">
						<label class="col-sm-2 control-label must">快递单号</label>
						<div class="col-sm-9 col-xs-12">
							<input type="text" name="expresssn" class="form-control" value="{$item['expresssn']}" data-rule-required='true' />
						</div>
					</div>
				{if $order_goods}
					<div class="form-group">
						<label class="col-sm-2 control-label">发货类型</label>
						<div class="col-sm-9 col-xs-12">
							<label class="radio-inline"><input type="radio" name="sendtype" value="0" {if $item['sendtype']>0}disabled="disabled"{/if}  {if empty($item['sendtype'])}checked="true"{/if}/> 按订单发货</label>
							<label class="radio-inline"><input type="radio" name="sendtype" value="1" {if $item['sendtype']>0}disabled="disabled"{/if} {if $item['sendtype']>0}checked="true"{/if}   /> 商品分包裹发货</label>
							<span class="help-block">选择商品发货类型</span>
						</div>
					</div>
					<div class="form-group sendpress" {if $item['sendtype']==0}style="display: none;"{/if}>
						<label class="col-sm-2 control-label">发货商品</label>
						<div class="col-sm-9 col-xs-12">
							{if $item['sendtype'] > 0}
							<ul id="myTab" class="nav nav-tabs">
								<li class="active"><a href="#noshipped" data-toggle="tab">未发货</a></li>
								<li><a href="#shipped" data-toggle="tab">已发货</a></li>
							</ul>
							<div id="myTabContent" class="tab-content">
								<div class="tab-pane fade in active" id="noshipped">
									<div class="alert alert-danger">
										请选择需要发货的商品
									</div>
									{loop $noshipped $k $g}
									<label class="fui-goods-list checkbox-inline row">
										<span class="col-sm-1">
											{if $g['sendtype']==0}
											<input type="checkbox" name="ordergoodsid[]"  value="{$g['id']}" {if !empty($item['quality'])}checked="true"{/if}   />
											{/if}
											<img src="{php echo tomedia($g['thumb'])}" width="25" height="25" alt="">
										</span>
										<span class="col-sm-11" style="height:25px;line-height: 25px;display: block;overflow: hidden;">
											{if $g['ispresell']==1}<label class="fui-tag fui-tag-danger">预</label>{/if}{$g['title']}
										</span>
									</label>
									{/loop}
								</div>
								<div class="tab-pane fade" id="shipped">
									{loop $shipped $k $b}
									<label class="fui-goods-list checkbox-inline row" style="padding:0;">
										<span class="col-sm-2">
											<label class="fui-tag fui-tag-danger">包裹{$b['sendtype']}</label>
										</span>
										<div class="col-sm-10">
											{loop $b['goods'] $g}
											<div class="row" style="margin:0;padding-bottom:5px">
											   <span class="col-sm-1">
													<img src="{php echo tomedia($g['thumb'])}" width="25" alt="">
											   </span>
												<span class="col-sm-11" style="height:25px;line-height: 25px;display: block;overflow: hidden;padding-left:3px;">
													{if $g['ispresell']==1}<label class="label label-danger" style="padding:2px 4px;margin-right:3px;">预售</label>{/if}{$g['title']}
												</span>
											</div>
											{/loop}
										</div>
									</label>
									{/loop}
								</div>
							</div>
							{else}
							{loop $order_goods $k $g}
							<label class="fui-goods-list checkbox-inline row">
								<span class="col-sm-1">
									{if $g['sendtype']==0}
									<input type="checkbox" name="ordergoodsid[]"  value="{$g['id']}" {if !empty($item['quality'])}checked="true"{/if}   />
									{/if}
									<img src="{php echo tomedia($g['thumb'])}" width="25" height="25" alt="">
								</span>
								<span class="col-sm-11" style="height:25px;line-height: 25px;display: block;overflow: hidden;">
									{if $g['ispresell']==1}<label class="fui-tag fui-tag-danger">预</label>{/if}{$g['title']}
								</span>
							</label>
							{/loop}
							{/if}
						</div>
					</div>
			   		{/if}
				{if $bundles}
			   <div class="form-group">
				   <label class="col-sm-2 control-label must">选择包裹</label>
				   <div class="col-sm-9 col-xs-12">
					   <div class="alert alert-danger">
						   请选择需要修改的包裹
					   </div>
					   {loop $bundles $k $b}
					   <label class="fui-goods-list checkbox-inline row" style="padding:0;">
							<span class="col-sm-1">
								<input type="radio" name="bundle" style="margin-top:5px;" value="{$b['sendtype']}"/>
							</span>
						   <div class="col-sm-11" style="padding:5px 0;">
								{loop $b['goods'] $g}
							   <div class="row" style="margin:0;padding-bottom:5px">
								   <span class="col-sm-1">
										<img src="{php echo tomedia($g['thumb'])}" width="25" alt="">
								   </span>
									<span class="col-sm-11" style="height:25px;line-height: 25px;display: block;overflow: hidden;">
										{if $g['ispresell']==1}<label class="label label-danger" style="padding:2px 4px;margin-right:3px;">预售</label>{/if}{$g['title']}
									</span>
							   </div>
								{/loop}
						   </div>
					   </label>
					   {/loop}
				   </div>
			   </div>
			   {/if}

			   {if $sendgoods}
			   <div class="form-group">
				   <label class="col-sm-2 control-label must">包裹商品</label>
				   <div class="col-sm-9 col-xs-12">
					   <label class="fui-goods-list checkbox-inline row" style="padding:0;">
						   <div class="col-sm-11" style="padding:5px 0;">
							   <div class="row" style="margin:0;padding-bottom:5px">
								   <span class="col-sm-1">
										<img src="{php echo tomedia($sendgoods['thumb'])}" width="25" alt="">
								   </span>
									<span class="col-sm-11" style="height:25px;line-height: 25px;display: block;overflow: hidden;">
										{if $sendgoods['ispresell']==1}<label class="label label-danger" style="padding:2px 4px;margin-right:3px;">预售</label>{/if}{$sendgoods['title']}
									</span>
							   </div>
						   </div>
					   </label>
				   </div>
			   </div>
			   {/if}

            </div>
            <div class="modal-footer">
                <button class="btn btn-primary" type="submit">{if $edit_flag==1}保存信息{else}确认发货{/if}</button>
                <button data-dismiss="modal" class="btn btn-default" type="button">取消</button>
            </div>
        </div>
</form>

<script language="javascript">
    $("select[name=express]").val("{if !empty($item['expresssn'])}{$item['express']}{else}{$item['dispatchkey']}{/if}");

    $("#express").change(function () {
        var obj = $(this);
        var sel = obj.find("option:selected").attr("data-name");
        $("#expresscom").val(sel);
    });

	$("input[name=sendtype]").off("click").on("click",function(){
		window.sendtype = $(this).val();
		if(window.sendtype==1){
			$(".sendpress").show();
		}else{
			$(".sendpress").hide();
		}
	});

    $("#express").change();

</script>



